ARCH := riscv64gc-unknown-none-elf
KERNEL_ENTRY_PA := 0x80200000
KERNEL_BIN := target/${ARCH}/release/os.bin
BOOTLOADER := ../../bootloader/rustsbi-qemu.bin

build:
	cargo build --release
	rust-objcopy --strip-all target/${ARCH}/release/os -O binary ${KERNEL_BIN}

run: build
	qemu-system-riscv64 \
		-machine virt \
		-nographic \
		-bios ${BOOTLOADER} \
		-device loader,file=${KERNEL_BIN},addr=${KERNEL_ENTRY_PA}

debug: build
	qemu-system-riscv64 \
		-machine virt \
		-nographic \
		-bios ${BOOTLOADER} \
		-device loader,file=${KERNEL_BIN},addr=${KERNEL_ENTRY_PA} \
		-s -S